package siac.com.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class JPAHibernateUtil {
	private static final SessionFactory sessionFactory = buildSessionFactory();

	private static SessionFactory buildSessionFactory() {
		try {
			Configuration conf = new Configuration();
			conf.configure("hibernate.cfg.xml");
			return conf.buildSessionFactory();
		} catch (Throwable e) {
			System.out.println("Criação inicial do objecto SessionFactory falhou. Erro: " + e);
			throw new ExceptionInInitializerError(e);
		}
	}

	public static SessionFactory getSessionfactory() {
		return sessionFactory;
	}

}
